package fr.istia.gesstages.metier;

import fr.istia.gesstages.jpa.Apply;
import fr.istia.gesstages.jpa.Offer;
import fr.istia.gesstages.jpa.User;
import fr.istia.gesstages.jpa.UserType;
import java.util.HashMap;
import java.util.List;

public interface IMetier {
    
    User findUserById(int id);
    UserType findUserTypeById(int id);
    Offer findOfferById(int id);
    Apply findApplyByOfferAndUser(Offer o, User u);
    Apply findApplyById(int id);
    
    User findUserByLogin(String login);
    List<User> findUsersByType(UserType type);
    UserType findUserTypeByName(String name);
    
    List<Apply> findAppliesByUser(User user);
    List<Apply> findAppliesByOffer(Offer offer);
    
    List<Offer> findOffersNotAppliedBy(User u);
    List<Offer> findOffersNotAttributed();
    List<Offer> findOffersNotArchived();
    List<Offer> findOffersArchived();
    
    List<Offer> findAllOffers();
    List<Apply> findAllApplies();
    List<User> findAllUsers();
    List<UserType> findAllUserTypes();
    
    // CRUD
    Apply createApply(Apply a);
    User createUser(User u);
    Offer createOffer(Offer o);
    
    Apply updateApply(Apply a);
    User updateUser(User u);
    Offer updateOffer(Offer o);
    
    void deleteApply(Apply a);
    void deleteUser(User u);
    void deleteOffer(Offer o);
    
    HashMap<User, List<Apply>> findAppliesForEachUser();
    HashMap<User, List<Apply>> findAppliesForEachUserOfType(UserType type);
    HashMap<Offer, List<Apply>> findAppliesForEachOffer();
    boolean login(String login, String password);
    
    void deleteAllOffers();
    void deleteAllApplies();
}
